export const useAppContextTs = (apiItems: IApiItem[]) => {
    // 找一下，是否存在/api开头并/config结尾的api
    const configApi = apiItems.find((item) => item.url?.endsWith('/config'))
    let configUrl = '/api/act2025/testActivity/config'
    if (configApi && configApi.url) {
        configUrl = configApi.url
    }
    return `import { useRequestContext } from '@changba/funny'

/**
 * 获取活动引擎的后台配置
 */
export const useAppContext = useRequestContext({
	configURL: '${configUrl}',
	useEngine: true,
	// useLara: true,
	// useLink: true,
	// configService: 'MARIO',
	// onInit: (ctx) => {
	// 	ctx.mario.setBaseURL('${configUrl}')
	// },
})

// TS工具类型，获取函数的返回值类型
export type Returned<F extends (...args: any) => any> = Awaited<ReturnType<F>>

type IAppContextRes = Returned<typeof useAppContext>

// 活动配置
export type ActEngineActivityConfig = IAppContextRes['appConfig']
`
}
